<pre>  /**
   * The constants used in this Content Widget.
   */
  public static interface CwConstants extends Constants {
    String cwDatePickerBoxLabel();

    String cwDatePickerDescription();

    String cwDatePickerLabel();

    String cwDatePickerName();
  }

  /**
   * {@link ValueChangeHandler} used to set the value in the text box when the user selects a date
   */
  public static class MyDateValueChangeHandler implements ValueChangeHandler&lt;Date&gt; {
    private final Label text;

    public MyDateValueChangeHandler(Label text) {
      this.text = text;
    }

    public void onValueChange(ValueChangeEvent&lt;Date&gt; event) {
      Date date = event.getValue();
      String dateString = DateTimeFormat.getMediumDateFormat().format(date);
      text.setText(dateString);
    }
  }

  /**
   * An instance of the constants.
   */
  private final CwConstants constants;

  /**
   * Initialize this example.
   */
  @SuppressWarnings("deprecation")
  @Override
  public Widget onInitialize() {
    // Create a basic date picker
    DatePicker datePicker = new DatePicker();
    final Label text = new Label();

    // Set the value in the text box when the user selects a date
    datePicker.addValueChangeHandler(new MyDateValueChangeHandler(text));

    // create a date picker where years and months are selectable with drop down lists and where we
    // can navigate trough the years
    DatePicker advancedDatePicker = new DatePicker();
    advancedDatePicker.setYearArrowsVisible(true);
    advancedDatePicker.setYearAndMonthDropdownVisible(true);
    // show 51 years in the years dropdown. The range of years is centered on the selected date
    advancedDatePicker.setVisibleYearCount(51);

    final Label text2 = new Label();
    text2.getElement().getStyle().setMarginTop(15, Unit.PX);

    // Set the value in the text box when the user selects a date
    advancedDatePicker.addValueChangeHandler(new MyDateValueChangeHandler(text2));

    // Set the default value
    datePicker.setValue(new Date(), true);
    advancedDatePicker.setValue(new Date(), true);

    // Create a DateBox
    DateTimeFormat dateFormat = DateTimeFormat.getLongDateFormat();
    DateBox dateBox = new DateBox();
    dateBox.setFormat(new DateBox.DefaultFormat(dateFormat));
    dateBox.getDatePicker().setYearArrowsVisible(true);

    // Combine the widgets into a panel and return them
    VerticalPanel vPanel = new VerticalPanel();
    vPanel.add(new HTML(constants.cwDatePickerLabel()));
    vPanel.add(text);
    vPanel.add(datePicker);
    vPanel.add(text2);
    vPanel.add(advancedDatePicker);
    vPanel.add(new HTML(constants.cwDatePickerBoxLabel()));
    vPanel.add(dateBox);
    return vPanel;
  }

</pre>